Skip to content

Fixed: Font subsetting - incorrect placement of head checksum#849

Merged
nicolaasuni merged 1 commit intotecnickcom:mainfrom
jindrapetrik:subsetting_head_fix
Mar 1, 2026
Merged

Fixed: Font subsetting - incorrect placement of head checksum#849
nicolaasuni merged 1 commit intotecnickcom:mainfrom
jindrapetrik:subsetting_head_fix

Conversation

@jindrapetrik
Copy link
Contributor

Currently, during font subsetting, head checksum is calculated and placed on offset 8 after head table start,
but this is incorrect and causes overwriting head.offset field!

The checksum should be placed in offset 4 after the tag 'head'.

This PR fixes this.

For me, this fixed PDF display error on Adobe Reader and or not diplaying proper characters in Edge PDF viewer.

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@williamdes williamdes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a before and after pdf please?

@jindrapetrik
Copy link
Contributor Author

Yes, here:
before.pdf
after.pdf

Using code like this:

      $pdf = new \TCPDF();
      $pdf->AddFont('Unifont', '', PDF_FONTPATH . 'unifont.php', true);
      $pdf->setFont('Unifont', '', 16);
      $pdf->AddPage();
      $pdf->Write(16, "ABC");
      $pdf->Output('out.pdf', 'D');

(I am using TCPDF 6.4.4, but the problem is probably the same in current.)

@williamdes
Copy link
Contributor

Thanks
@nicolaasuni ready for your review

@nicolaasuni nicolaasuni merged commit a8808b9 into tecnickcom:main Mar 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants